package com.vueapi.controller.admin;

import com.vueapi.annotation.OperationLog;
import com.vueapi.service.HjExceptionLogService;
import com.vueapi.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Classname AdminCommentController
 * @Description TODO
 * @Created by 赵宏建
 * @Date 2023/8/3 16:36
 * @Version 1.0.0
 */
@RestController
@RequestMapping("/admin/exceptionLog")
public class AdminExceptionLogController {

    @Autowired
    private HjExceptionLogService exceptionLogService;

    @GetMapping("/list")
    public ResultUtils list(@RequestParam(defaultValue = "1") Integer pageNum,
                            @RequestParam(defaultValue = "10") Integer pageSize,
                            @RequestParam(required = false, defaultValue = "") String message) {
        return exceptionLogService.listPage(pageNum, pageSize, message);
    }

    @OperationLog(name = "删除日志")
    @GetMapping("/delete")
    public ResultUtils delete(@RequestParam String ids) {
        Boolean flag = exceptionLogService.exceptionDeleteByIds(ids);
        if(flag){
            return ResultUtils.success();
        }
        return ResultUtils.fail();
    }

    @OperationLog(name = "清空日志")
    @GetMapping("/deleteAll")
    public ResultUtils deleteAll(){
        exceptionLogService.remove(null);
        return ResultUtils.success();
    }

}
